<html>
<head><meta charset="utf-8"><title>Debugging broken MIR · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html">Debugging broken MIR</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="204178630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204178630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204178630">(Jul 17 2020 at 07:42)</a>:</h4>
<p>I'm trying to make a change to how we generate closure capture information for RFC 2229 and am running into errors. </p>
<p>Build log: <a href="http://csclub.uwaterloo.ca/~a52arora//rust-builds/log_357f4669-6a4a-43c7-817b-b54ae1131868">http://csclub.uwaterloo.ca/~a52arora//rust-builds/log_357f4669-6a4a-43c7-817b-b54ae1131868</a><br>
Can someone point me to some way of debugging the issue? </p>
<p>At a high level our changes are to add a new field in TypeCk Tables and use it to build the fields that currently store capture information and don't touch MIR (well directly)<br>
If we add something to TypecheckTables do we need to make changes anywhere else other than making initializing and making sure it's hash-stable? </p>
<p>diff if that helps: <a href="https://github.com/rust-lang/rust/compare/44c9ace...sexxi-goose:use_places">https://github.com/rust-lang/rust/compare/44c9ace...sexxi-goose:use_places</a></p>
<p>cc: <span class="user-mention" data-user-id="282522">@azhng</span></p>



<a name="204232176"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204232176" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204232176">(Jul 17 2020 at 17:06)</a>:</h4>
<p><span class="user-mention" data-user-id="281950">@Aman Arora</span> hmm</p>



<a name="204232188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204232188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204232188">(Jul 17 2020 at 17:06)</a>:</h4>
<p>so the first thing I would do is to run the compiler with <code>-Ztreat-err-as-bug</code> and <code>RUST_BACKTRACE=1</code></p>



<a name="204232209"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204232209" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204232209">(Jul 17 2020 at 17:06)</a>:</h4>
<p>this should cause the "delayed error" to flag as a bug and give you a backtrace with more information</p>



<a name="204232405"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204232405" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204232405">(Jul 17 2020 at 17:08)</a>:</h4>
<p>you can also use <code>-Zdump-mir='DefId(0:5988 '</code> to dump out all the MIR as you go so you can see the MIR that is failing. The string there is just some unique-looking part of the fn name</p>



<a name="204232442"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204232442" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204232442">(Jul 17 2020 at 17:09)</a>:</h4>
<p>it'd be helpful to see the MIR that is being generated</p>



<a name="204234055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204234055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204234055">(Jul 17 2020 at 17:24)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/122651-general/topic/Debugging.20broken.20MIR/near/204232405">said</a>:</p>
<blockquote>
<p>you can also use <code>-Zdump-mir='DefId(0:5988 '</code> to dump out all the MIR as you go so you can see the MIR that is failing. The string there is just some unique-looking part of the fn name</p>
</blockquote>
<p>Will DefId stay the same between two builds?</p>



<a name="204234305"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204234305" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204234305">(Jul 17 2020 at 17:26)</a>:</h4>
<p>They should be</p>



<a name="204234412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204234412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204234412">(Jul 17 2020 at 17:27)</a>:</h4>
<p>This might be a stupid question but how do I pass the compiler flags using x.py? Is it using the RUSTFLAGS env variable ?</p>



<a name="204234567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204234567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204234567">(Jul 17 2020 at 17:29)</a>:</h4>
<p><code>./x.py cmd --rustc-args ...</code></p>



<a name="204234632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204234632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204234632">(Jul 17 2020 at 17:29)</a>:</h4>
<p>wait, that's a thing?</p>



<a name="204234647"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204234647" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204234647">(Jul 17 2020 at 17:29)</a>:</h4>
<p>I do not recall that being added</p>



<a name="204234705"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204234705" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204234705">(Jul 17 2020 at 17:30)</a>:</h4>
<p>I am fairly sure it is, considering how often I use it <span aria-label="laughter tears" class="emoji emoji-1f602" role="img" title="laughter tears">:laughter_tears:</span></p>



<a name="204234799"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204234799" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204234799">(Jul 17 2020 at 17:30)</a>:</h4>
<p>The documentation said that is only for running tests</p>
<div class="codehilite"><pre><span></span><code>--rustc-args ARGS
                        extra options to pass the compiler when running tests
</code></pre></div>



<a name="204234842"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204234842" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204234842">(Jul 17 2020 at 17:31)</a>:</h4>
<p>I'll give this a shot, thank you</p>



<a name="204235341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204235341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204235341">(Jul 17 2020 at 17:35)</a>:</h4>
<p>Personally I use <code>rustup toolchain link</code> so I don't have to mess with bootstrap more than I have to lol</p>



<a name="204235406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204235406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204235406">(Jul 17 2020 at 17:36)</a>:</h4>
<p>So my workflow is something like <code>x.py build --stage 1 src/librustdoc &amp;&amp; rustdoc +stage1 my_test.rs -Z my_args</code></p>



<a name="204236281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204236281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204236281">(Jul 17 2020 at 17:44)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/122651-general/topic/Debugging.20broken.20MIR/near/204235341">said</a>:</p>
<blockquote>
<p>Personally I use <code>rustup toolchain link</code> so I don't have to mess with bootstrap more than I have to lol</p>
</blockquote>
<p>I'm trying to get the compiler to compile with the flags rn, haha</p>



<a name="204258617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204258617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204258617">(Jul 17 2020 at 21:01)</a>:</h4>
<p>So using <code>./x.py ... --rustc-args="-..."</code> didn't do anything</p>
<p>I used RUSTFLAGS enivroment variable, here is the log<br>
<a href="http://csclub.uwaterloo.ca/~a52arora/rust-builds/log_fa134c64-4d37-415b-9e51-40e66ffabfb4">http://csclub.uwaterloo.ca/~a52arora/rust-builds/log_fa134c64-4d37-415b-9e51-40e66ffabfb4</a></p>
<p>I wasn't able to set the def if to all of <code>DefId(0:5988 ~ core[de9c]::fmt[0]::builders[0]::{{impl}}[1]::wrap[0]::{{closure}}[0])</code>, tried escaping all the single quotes, spaces etc. as well but it diddn't work</p>
<p>If <code>DefId(0:5988</code> is enough where would the mir output be? Nothing particular in the build directory caught my eye</p>



<a name="204369374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204369374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204369374">(Jul 19 2020 at 20:24)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span>  do you have any tips on how I can proceed?</p>



<a name="204369489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204369489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204369489">(Jul 19 2020 at 20:28)</a>:</h4>
<p>not really <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span> I don't have too much experience with debugging mir</p>



<a name="204369493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204369493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204369493">(Jul 19 2020 at 20:28)</a>:</h4>
<p>apart from the default debugging experience of looking at the backtrace I don't think I can be of much help here</p>



<a name="204369504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204369504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204369504">(Jul 19 2020 at 20:29)</a>:</h4>
<p>what happens with <code>./x.py ... --rustc-args -Zdump-mir='DefId(0'</code>?</p>



<a name="204369648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204369648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204369648">(Jul 19 2020 at 20:32)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/122651-general/topic/Debugging.20broken.20MIR/near/204369504">said</a>:</p>
<blockquote>
<p>what happens with <code>./x.py ... --rustc-args -Zdump-mir='DefId(0'</code>?</p>
</blockquote>
<p>that didn't change the output for me. It was same as without the args. Like when I provide -Ztreat-err-as-bug in RUSTFLAGS it quits early with the message saying quiting early because of the flag&gt;</p>
<p>When I use -rustc-args i don't get the message</p>



<a name="204369658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204369658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204369658">(Jul 19 2020 at 20:33)</a>:</h4>
<p>Based on the help from bootstap <br>
--rustc-args ARGS<br>
                        extra options to pass the compiler when running tests</p>
<p>I think that is expected because currently it fails to build the stage1 compiler i.e. it is not running tests</p>



<a name="204369790"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204369790" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204369790">(Jul 19 2020 at 20:36)</a>:</h4>
<p>is it failing in stage 1 libs or stage 2 compiler?</p>



<a name="204369806"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204369806" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204369806">(Jul 19 2020 at 20:37)</a>:</h4>
<p>stage 1</p>



<a name="204369810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204369810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204369810">(Jul 19 2020 at 20:37)</a>:</h4>
<p>stage 1 libs, yeah... looked at the logs</p>



<a name="204369870"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204369870" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204369870">(Jul 19 2020 at 20:39)</a>:</h4>
<p>hmm, maybe <span class="user-mention" data-user-id="124288">@oli</span> or <span class="user-mention" data-user-id="125250">@Wesley Wiser</span> have an idea on how to debug mir if it fails to compile stage 1 libs <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="204370651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204370651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204370651">(Jul 19 2020 at 21:02)</a>:</h4>
<p>You can try running bootstrap with <code>RUSTC_LOG=rustc_mir::transform</code> to see the MIR but if you don't know what's going wrong, that's probably going to be too much data to be helpful.</p>



<a name="204370661"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204370661" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204370661">(Jul 19 2020 at 21:03)</a>:</h4>
<p>Can you only run your changes if a <code>-Z</code> flag is passed or something? That would let you complete the bootstrap and then you can run the test suite with the flag enabled to find a smaller repro.</p>



<a name="204370853"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204370853" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204370853">(Jul 19 2020 at 21:09)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125250">Wesley Wiser</span> <a href="#narrow/stream/122651-general/topic/Debugging.20broken.20MIR/near/204370661">said</a>:</p>
<blockquote>
<p>Can you only run your changes if a <code>-Z</code> flag is passed or something? That would let you complete the bootstrap and then you can run the test suite with the flag enabled to find a smaller repro.</p>
</blockquote>
<p>I like this idea, are there any code examples where I can see how -Z flags are added to the compiler?</p>



<a name="204370861"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204370861" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204370861">(Jul 19 2020 at 21:09)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125250">Wesley Wiser</span> <a href="#narrow/stream/122651-general/topic/Debugging.20broken.20MIR/near/204370651">said</a>:</p>
<blockquote>
<p>You can try running bootstrap with <code>RUSTC_LOG=rustc_mir::transform</code> to see the MIR but if you don't know what's going wrong, that's probably going to be too much data to be helpful.</p>
</blockquote>
<p>Yeah, I'm not familiar with MIR at all, so I'd only be making guesses</p>



<a name="204370905"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204370905" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204370905">(Jul 19 2020 at 21:10)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/issues/69749">#69749</a> adds a new feature flag, though the pr is quite big</p>



<a name="204370907"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204370907" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204370907">(Jul 19 2020 at 21:10)</a>:</h4>
<p>there is probably a smaller pr to reference here</p>



<a name="204370918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204370918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204370918">(Jul 19 2020 at 21:11)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281950">Aman Arora</span> <a href="#narrow/stream/122651-general/topic/Debugging.20broken.20MIR/near/204370853">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="125250">Wesley Wiser</span> <a href="#narrow/stream/122651-general/topic/Debugging.20broken.20MIR/near/204370661">said</a>:</p>
<blockquote>
<p>Can you only run your changes if a <code>-Z</code> flag is passed or something? That would let you complete the bootstrap and then you can run the test suite with the flag enabled to find a smaller repro.</p>
</blockquote>
<p>I like this idea, are there any code examples where I can see how -Z flags are added to the compiler?</p>
</blockquote>
<p>Take a look at this commit <a href="https://github.com/rust-lang/rust/pull/74275/commits/2acd1495200d58b5a3b44365268c17b973e0e8d3">https://github.com/rust-lang/rust/pull/74275/commits/2acd1495200d58b5a3b44365268c17b973e0e8d3</a></p>



<a name="204371153"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204371153" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204371153">(Jul 19 2020 at 21:18)</a>:</h4>
<p>If I understand this properly</p>
<div class="codehilite"><pre><span></span><code>    cgu_partitioning_strategy: Option&lt;String&gt; = (None, parse_opt_string, [TRACKED],
        &quot;the codegen unit partitioning strategy to use&quot;),
</code></pre></div>


<p>the name of the field <code>cgu_partitioning_strategy</code> becomes the -Zcgu_partitioning_strategy flag, </p>
<ul>
<li>the first element in the tuple is default argument,</li>
<li>next one suggests that this might be called with an optional string paramter,</li>
<li>Not sure what is being [TRACKED]  here though? Is it just for build logs?  </li>
<li>Last field is just the descripton</li>
</ul>



<a name="204373432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204373432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204373432">(Jul 19 2020 at 22:25)</a>:</h4>
<p>For pure hackery, you could maybe skip the code in question unless an environment variable is set.</p>



<a name="204373563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204373563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204373563">(Jul 19 2020 at 22:29)</a>:</h4>
<p>May be easier than plumbing in the option</p>



<a name="204373745"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204373745" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204373745">(Jul 19 2020 at 22:35)</a>:</h4>
<p>Okay that works too, thank you</p>



<a name="204406990"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204406990" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204406990">(Jul 20 2020 at 10:35)</a>:</h4>
<p>just a slight note</p>
<div class="codehilite"><pre><span></span><code>the name of the field `cgu_partitioning_strategy` becomes the -Zcgu_partitioning_strategy flag,
</code></pre></div>


<p>it's going to become <code>-Z cgu-partitioning-strategy</code></p>



<a name="204616891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204616891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204616891">(Jul 21 2020 at 23:56)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116113">lqd</span> <a href="#narrow/stream/122651-general/topic/Debugging.20broken.20MIR/near/204406990">said</a>:</p>
<blockquote>
<p>just a slight note</p>
<div class="codehilite"><pre><span></span><code>the name of the field `cgu_partitioning_strategy` becomes the -Zcgu_partitioning_strategy flag,
</code></pre></div>


<p>it's going to become <code>-Z cgu-partitioning-strategy</code></p>
</blockquote>
<p>Thank you, I think right now we might just go with the env variable mostly because we don't exect this part of the code to be controlled by flag once we are done debugging</p>



<a name="204616917"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/204616917" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#204616917">(Jul 21 2020 at 23:57)</a>:</h4>
<p>def good to know for the future tho</p>



<a name="205158453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Debugging%20broken%20MIR/near/205158453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Debugging.20broken.20MIR.html#205158453">(Jul 27 2020 at 19:30)</a>:</h4>
<p>Thanks the environment variable method worked. If anyone is interested the issues were:</p>
<ul>
<li>We weren't handling ByValue captures in a part of the analysis</li>
<li>We have two structures today that store capture information, one that is generated before typechk and one after typechk. mir_build uses a mix of both. Today the order of captures within both the structures is the same and our change broke that order. Fix was just to the post typechl structure.<br>
Haven't looked at the code yet, so just speculating but ExprUseVisitor in typeck seems might be iterating in a different order than hir::intravisitor</li>
</ul>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>